<template>
  <div id="ConvergenceSystem">
    <div class="child-system-header">
      <div
        @click="handleMenuClick('TerminalResource')"
        :class="activeMenu === 'TerminalResource' ? 'active' : ''"
        class="menu-item"
      >
        终端汇聚
      </div>
      <div
        @click="handleMenuClick('LiveResource')"
        :class="activeMenu === 'LiveResource' ? 'active' : ''"
        class="menu-item"
      >
        直播汇聚
      </div>
      <div
        @click="handleMenuClick('VodResource')"
        :class="activeMenu === 'VodResource' ? 'active' : ''"
        class="menu-item"
      >
        点播汇聚
      </div>
    </div>
    <div class="child-system-content">
      <router-view></router-view>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { useRouter, useRoute } from "vue-router";

const router = useRouter();
const route = useRoute();

// 获取当前路由
const activeMenu = ref("LiveResource");
const currentRouteName = route.name;
if (currentRouteName === "TerminalResource") {
  activeMenu.value = "TerminalResource";
} else if (currentRouteName === "LiveResource") {
  activeMenu.value = "LiveResource";
} else if (currentRouteName === "VodResource") {
  activeMenu.value = "VodResource";
}

// 菜单点击
function handleMenuClick(menuName: string) {
  activeMenu.value = menuName;
  router.push({
    name: menuName,
  });
}
</script>

<style scoped lang="scss">
#ConvergenceSystem {
  width: 100%;
  height: 100%;
}
.child-system-header {
  display: flex;
  align-items: center;
  height: 5rem;
  padding: 0 1.5rem;
  background-color: #fff;
  border-radius: 5px;
  .menu-item {
    margin-right: 6rem;
    font-size: $font-size-page-menu;
    color: $text-color-secondary;
    cursor: pointer;
  }
  .menu-item.active {
    color: $text-color-primary;
    background: url("~@/assets/images/underline.png") no-repeat center
      bottom/100% auto;
  }
}
.child-system-content {
  height: calc(100% - 5rem);
  padding-top: 2rem;
}
</style>
